-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
csharp: improve performance and reduce memory footprint when creating and verifying webhook signatures #1616
csharp: improve performance and reduce memory footprint when creating and verifying webhook signatures #1616
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the contribution, and sorry to hear the current code was thrashing the GC.
I made some comments about specific changes (not all of them yet), though would you mind opening smaller PRs that are more focused on just one change so that things are easier to review?
At the moment there are 4+ completely separate changes here which make it very hard to: (1) understand the reasoning behind each change / need, and (2) understanding what's going on so that we can review it effectively.
Thanks a lot!
Will do. I will also make some comments to your questions here. |
I concentrated on the span vs string changes in this PR only; also added benchmarks to see the real benefit |
… WebHeaderCollection (#1617) Provide an overload to the `Webhook.Verify` function to except an `Func<string, string>` function that acts as an function provider. <!-- Thank you for your Pull Request. Please provide a description above and review the requirements below. Bug fixes and new features should include tests. --> ## Motivation Creating an extra `WebHeaderCollection` everytime a webhook signature needs to get verified is unnecessary overhead for environments where the `WebHeaderCollection` is not part of underlying http stack; The object needs to get created just for the verification. ## Solution Allowing to pass a header provider function to avoid creating a WebHeaderCollection in asp.net core environments See also #1616
Can you please rebase over |
…ng and signing webhooks
…oid the need to create a WebHeaderCollection when using asp.net core
ffa916b
to
fb5b361
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made one last comment that I found in the latest review, but looks good otherwise.
Thanks a lot! |
Using latest csharp and dotnet features to increase performance and reduce memory footprint when creating and verifying webhook signatures
Motivation
When using the webhook verification process we see lots of memory wasted and garbage collector kicking when our applications gets hit with a lot of webhook requests.
Solution
Benchmarks
Original Code
Code from this PR